package com.example.raspberryPi_demo.service;

import com.example.raspberryPi_demo.entity.CollectedData;
import com.example.raspberryPi_demo.mapper.CollectedDataDAO;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class CollectedDataService {
    @Autowired
    CollectedDataDAO collectedDataDAO;

    public CollectedData findCollectedDataByTimeStamp(Integer timestamp) {
        return collectedDataDAO.selectByPrimaryKey(timestamp);
    }

    public CollectedData findCollectedDataByMacAddress(String macAddress) {
        return collectedDataDAO.selectByMacAddress(macAddress);
    }

    public List<CollectedData> findCollectedDataList() {
        return collectedDataDAO.selectAll();
    }

    //需要用到sql的where 大于小于
    public List<CollectedData> findCollectedDataByTimeBucket(String startTime, String endTime) {
        return collectedDataDAO.selectByTimeBucket(startTime,endTime);
    }

    public int delete(Integer timestamp) {
        return collectedDataDAO.deleteByPrimaryKey(timestamp);
    }

    public int update(Integer timestamp,CollectedData collectedData) {
        return collectedDataDAO.updateByPrimaryKey(timestamp,collectedData);
    }

    public int save(CollectedData collectedData) {
        return collectedDataDAO.insert(collectedData);
    }


}
